import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        /*
         * Number of daffodils
         * 求出0～n之间的所有“水仙花数”并输出。
         * (“水仙花数”是指一个三位数，
         * 其各位数字的立方和确好等于该数本身，
         * 如；153＝1^3＋5^3＋3^3，
         * 则153是一个“水仙花数“。）*/
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入n:");
        int input = scanner.nextInt();
        for (int i = 1; i < input; i++) {
            int count = 0;
            int sum = 0;
            int temp = i;

            //计算位数
            while (temp != 0) {
                temp /= 10;
                count++;
            }

            temp = i;
            while (temp != 0) {
                sum += (int) Math.pow(temp % 10, count);
                temp /= 10;
            }
            if (sum == i) {
                System.out.println(i);
            }
        }
    }
}
